package com.scheuk.euler;

import com.scheuk.euler.MathTools;

public class p005 {

	/* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
	 * What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
	 * NOTE: wow this is SLOW via brute force. need to redo this to be faster... use PRIMES.
	 *  
	 */
	static void bruteForce(int max) {
		int gdn = max * (max - 1);
		for (int i = 1; i < max+1; i++) {
			int remainder = gdn%i;
			if (remainder != 0) {
				gdn+=remainder;
				i=3; //reset and start over
				System.out.println("new gdn: " + gdn);
			}
		}
		System.out.println("smallest positive number evenly divisible from 1-" + max + ": " + gdn);
	}

	static void Problem5useLCM(int max) {
		long result = (long) max;
		int i = max;
		while(i > 2)
		{
			result = MathTools.lcm(i-2,  i-1, result);
			i-=2;
		}
		System.out.println("smallest positive number evenly divisible from 1-" + max + ": " + result);
	}
}
